]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensions: Unify how manager is injected into shared module
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 9 Jul 2023 10:47:05 +0000 (12:47 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 15 Jul 2023 11:16:42 +0000 (13:16 +0200)
We unified most code paths earlier, but the common code will still
import Main locally if no extension manager was injected before.

Now that the old extensionUtils was split between extension and
preferences, each of those modules can simply import the manager
from its corresponding environment, and then inject it into the
shared module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2837>

js/dbusServices/extensions/extensionsService.js
js/extensions/extension.js
js/extensions/prefs.js
js/extensions/sharedInternals.js

index f0c93f6cbab1c11d5f4a08b0707d3c2912e144ea..b8e571bf93f45edfe354aefd1137c32cf88d274e 100644 (file)
@@ -5,7 +5,6 @@ import Shew from 'gi://Shew';
 
 import {ExtensionPrefsDialog} from './extensionPrefsDialog.js';
 import {ServiceImplementation} from './dbusService.js';
-import {setExtensionManager} from './extensions/sharedInternals.js';
 
 const {deserializeExtension} = imports.misc.extensionUtils;
 const {loadInterfaceXML} = imports.misc.dbusUtils;
@@ -27,8 +26,7 @@ class ExtensionManager {
     }
 }
 
-const extensionManager = new ExtensionManager();
-setExtensionManager(extensionManager);
+export const extensionManager = new ExtensionManager();
 
 export const ExtensionsService = class extends ServiceImplementation {
     constructor() {
index b9e72584a95f0e865f331e992050a9c7ba3560bd..a2c383e00dd375f6060ed0b7134ceb1642790aa9 100644 (file)
@@ -1,4 +1,4 @@
-import {getCurrentExtension} from './sharedInternals.js';
+import {getCurrentExtension, setExtensionManager} from './sharedInternals.js';
 
 export {
     getSettings,
@@ -9,6 +9,7 @@ export {
 } from './sharedInternals.js';
 
 const {extensionManager} = imports.ui.main;
+setExtensionManager(extensionManager);
 
 /**
  * Open the preference dialog of the current extension
index 405b8614ea17afcb0b8699be2a994b9863c0f25f..61488e09d7e28c4b0a3677e391f2552b053f4403 100644 (file)
@@ -1,3 +1,8 @@
+import {setExtensionManager} from './sharedInternals.js';
+import {extensionManager} from '../extensionsService.js';
+
+setExtensionManager(extensionManager);
+
 export {
     getSettings,
     initTranslations,
index c2133936c07078c0fd4414d1c97a6f4c7f80a8d7..c8a02471dde2cdfcdea5223de4d1238349fb8c5c 100644 (file)
@@ -35,11 +35,6 @@ export function getCurrentExtension() {
     if (!extensionLine)
         return null;
 
-    // local import, as the module is used from outside the gnome-shell process
-    // as well
-    if (!_extensionManager)
-        setExtensionManager(imports.ui.main.extensionManager);
-
     // The exact stack line differs depending on where the function
     // was called (function or module scope), and whether it's called
     // from a module or legacy import (file:// URI vs. plain path).